import { defineStore } from "pinia";

import type { UserInfo, State } from "./type/type";

export const useUserStore = defineStore({
  id: "USER_INFO",
  state: (): State => {
    return {
      userInfo: {
        code: 'vX7kYhyEVqOcFWJn',
        avatar: "",
        code_num: "",
        token: "",
        username: "",
        store_name: "",
        username_num: 0,
        goods: {}
      },
      token: "11",
    };
  },

  actions: {
    saveUserInfo(userInfo: UserInfo) {
      this.userInfo = userInfo;
    },
    saveToken(token: any) {
      this.token = token;
    }
  },

  getters: {},

  persist: {
    enabled: true,
    storage: sessionStorage,
  }
});
